//
//  UiLable + Extension.swift
//  WeiBoYH
//
//  Created by yanhui on 2017/1/6.
//  Copyright © 2017年 yanhui. All rights reserved.
//

import UIKit

//UILable的扩展方法
extension UILabel{
    convenience init(text: String, fontSize: CGFloat, textColor: UIColor){
        self.init()
        //给lable设置属性
        self.text = text
        self.numberOfLines = 0
        self.font = UIFont.systemFont(ofSize: fontSize)
        self.textColor = textColor
        self.sizeToFit()
        
    }
    
}


//UIButton的扩展方法
extension UIButton{
    convenience init(backImageName: String, text: String, fontSize: CGFloat, textColor: UIColor){
        self.init()
        self.setBackgroundImage(UIImage(named: backImageName), for: .normal)
        self.setTitle(text, for: .normal)
        self.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        self.setTitleColor(textColor, for: .normal)
        self.sizeToFit()
        
    }
   
}


//给UIColor扩充方法
extension UIColor {
    //随机色
    class var randomColor: UIColor {
        let r = CGFloat(arc4random() % 256) / 255.0
        let g = CGFloat(arc4random() % 256) / 255.0
        let b = CGFloat(arc4random() % 256) / 255.0
        return UIColor(red: r, green: g, blue: b, alpha: 1)
    }
}

